package com.kangfu.common.utils;

import okhttp3.HttpUrl;

import java.util.HashMap;
import java.util.Map;

public class UrlUtils {

    /**
     * 把get参数拼接到url后面
     * @param url
     * @param params
     * @return
     */
    public static String parseParams(String url, HashMap<String, String> params) {
        HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
        for (Map.Entry < String, String > entry: params.entrySet()) {
            urlBuilder.addQueryParameter(entry.getKey(), entry.getValue());
        }
        return urlBuilder.build().toString();
    }
}
